package com.free.semantic.web.result;

public class Result<T> {

    private boolean isSuccess;

    private T result;

    private String errorCode;

    private String errorMessage;

    public static <R> Result<R> success(R result) {
        Result<R> res = new Result<>();
        res.setResult(result);
        res.setSuccess(true);
        return res;
    }

    public static <R> Result<R> fail(String error) {
        Result<R> res = new Result<>();
        res.setSuccess(false);
        res.setErrorMessage(error);
        return res;
    }

    public boolean isSuccess() {
        return isSuccess;
    }

    public void setSuccess(boolean success) {
        isSuccess = success;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

}

